package 反射第一遍.demo15;

import java.lang.reflect.Method;

/**
 * @author wql
 * @version 1.0
 * @date 2022/10/27 15:27
 */

public class Test {
    public static void main(String[] args) throws Exception{
        Class<rose> roseClass = rose.class;
        Object rose = roseClass.newInstance();

        Method sting = roseClass.getDeclaredMethod("sting");
        Object invoke = sting.invoke(rose);
        System.out.println("invoke = " + invoke);

        Method eat = roseClass.getDeclaredMethod("eat", String.class, Integer.class);
        Object haha = eat.invoke(rose, "不可", 5555);
        System.out.println("haha = " + haha);
    }
}
class  flower{
    public void show(){
        System.out.println("花儿的show");
    }
    public void print(){
        System.out.println("花儿的print");
    }
}
class rose extends flower{
    public void sting(){
        System.out.println("玫瑰的sting");
    }
    public String eat(String name,Integer num){
        System.out.println("玫瑰的eat"+num);
        return "niubi";
    }
}
